package com.hai.qtalk.bean;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.hai.qtalk.bean.User;

/**
 * 用于将用户之间发送的信息存入数据库的实体类，该功能暂未实现 
 * @author xinhai
 */
@Entity
@Table(name = "message", catalog = "mydb")
public class Message implements java.io.Serializable {

	// Fields

	private Integer MId;
	private User userByMSender;
	private User userByMReceiver;
	private String MContent;
	private Date MTime;
	private boolean MState;
	private boolean MType;

	// Constructors

	/** default constructor */
	public Message() {
	}

	/** full constructor */
	public Message(User userByMSender, User userByMReceiver, String MContent,
			Date MTime, boolean MState, boolean MType) {
		this.userByMSender = userByMSender;
		this.userByMReceiver = userByMReceiver;
		this.MContent = MContent;
		this.MTime = MTime;
		this.MState = MState;
		this.MType = MType;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "m_id", unique = true, nullable = false)
	public Integer getMId() {
		return this.MId;
	}

	public void setMId(Integer MId) {
		this.MId = MId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "m_sender")
	public User getUserByMSender() {
		return this.userByMSender;
	}

	public void setUserByMSender(User userByMSender) {
		this.userByMSender = userByMSender;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "m_receiver")
	public User getUserByMReceiver() {
		return this.userByMReceiver;
	}

	public void setUserByMReceiver(User userByMReceiver) {
		this.userByMReceiver = userByMReceiver;
	}

	@Column(name = "m_content", length = 200)
	public String getMContent() {
		return this.MContent;
	}

	public void setMContent(String MContent) {
		this.MContent = MContent;
	}

	@Column(name = "m_time", length = 19)
	public Date getMTime() {
		return this.MTime;
	}

	public void setMTime(Date MTime) {
		this.MTime = MTime;
	}

	@Column(name = "m_state")
	public boolean getMState() {
		return this.MState;
	}

	public void setMState(boolean MState) {
		this.MState = MState;
	}

	@Column(name = "m_type")
	public boolean getMType() {
		return this.MType;
	}

	public void setMType(boolean MType) {
		this.MType = MType;
	}

}